home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 019a / tde10src.zip / TDESTR.H < prev    next >
C/C++ Source or Header  |  1991-06-05  |  10KB  |  266 lines

  1. /*******************  start of original comments  ********************/
  2. /*
  3.  * Written by Douglas Thomson (1989/1990)
  4.  *
  5.  * This source code is released into the public domain.
  6.  */
  7.  
  8. /*
  9.  * This file contains all the includes, defines, types and function
  10.  *  prototypes that are common to all the editor modules.
  11.  */
  12. /*********************  end of original comments   ********************/
  13.  
  14. /*
  15.  * New editor name:  tde, the Thomson-Davis Editor.
  16.  * Author:           Frank Davis
  17.  * Date:             June 5, 1991
  18.  *
  19.  * This modification of Douglas Thomson's code is released into the
  20.  * public domain, Frank Davis.  You may distribute it freely.
  21.  *
  22.  * This file contains all the structure declarations and defines common
  23.  *  to all the editor modules.
  24.  */
  25.  
  26. #define MAX_KEYS           400
  27.  
  28. #define MAX_COLS            80  /* widest screen ever used */
  29. #define MAX_LINES           24  /* highest screen ever used */
  30. #define BUFF_SIZE          256  /* buffer size for lines */
  31. #define MAX_LINE_LENGTH    255  /* longest line allowed in file */
  32.  
  33. #define ERROR     (-1)          /* abnormal termination */
  34. #define OK        0             /* normal termination */
  35. #define TRUE      1             /* logical true */
  36. #define FALSE     0             /* logical false */
  37.  
  38. #define RTURN     13            /* Return key = 13 */
  39. #define CONTROL_Z 26            /* Control z  = 26 or DOS eof character */
  40. #define ESC       27            /* Escape key = 27 */
  41.  
  42. /*
  43.  * The following defines are used by the "error" function, to indicate
  44.  *  how serious the error is.
  45.  */
  46. #define WARNING 1               /* user must acknowledge, editor continues */
  47. #define FATAL   2               /* editor aborts - very rare! */
  48.  
  49. /*
  50.  * define the type of block marked by user
  51.  */
  52. #define NOTMARKED  0            /* block type undefined */
  53. #define BLOCK      1            /* block marked by row and column */
  54. #define LINE       2            /* block marked by begin and end lines */
  55.  
  56. #define MOVE       1
  57. #define DELETE     2
  58. #define COPY       3
  59. #define KOPY       4
  60. #define FILL       5
  61. #define OVERLAY    6
  62.  
  63. #define LOCAL      1
  64. #define NOT_LOCAL  2
  65. #define GLOBAL     3
  66.  
  67. #define IGNORE     1
  68. #define MATCH      2
  69.  
  70. #define PROMPT     1
  71. #define NOPROMPT   2
  72.  
  73. #define FORWARD    1
  74. #define BACKWARD   2
  75.  
  76. #define BEGIN      1
  77. #define END        2
  78.  
  79. #define EXIST       0
  80. #define WRITE       2
  81. #define READ        4
  82. #define READ_WRITE  6
  83.  
  84. /*
  85.  * possible answers to various questions - see get_yn, get_ynaq and get_oa
  86.  */
  87. #define A_YES       1
  88. #define A_NO        2
  89. #define A_ALWAYS    3
  90. #define A_QUIT      4
  91. #define A_ABORT     5
  92. #define A_OVERWRITE 6
  93. #define A_APPEND    7
  94.  
  95. /*
  96.  * The following defines specify which video attributes give desired
  97.  *  effects on different display devices.
  98.  * REVERSE is supposed to be reverse video - a different background color,
  99.  *  so that even a blank space can be identified.
  100.  * HIGH is supposed to quickly draw the user's eye to the relevant part of
  101.  *  the screen, either for a message or for matched text in find/replace.
  102.  * NORMAL is supposed to be something pleasant to look at for the main
  103.  *  body of the text.
  104.  * These defines may not be optimal for all types of display. Eventually
  105.  *  the user should be allowed to select which attribute is used where.
  106.  */
  107. #define VIDEO_INT      0x10
  108.  
  109. #define LCD_REVERSE    0x70
  110. #define LCD_NORMAL     0x07
  111. #define LCD_HIGH       0x17
  112.  
  113. #define HERC_REVERSE   0x70
  114. #define HERC_UNDER     0x01
  115. #define HERC_NORMAL    0x07
  116. #define HERC_HIGH      0x0F
  117.  
  118. #define COLOR_HEAD     0x4b
  119. #define COLOR_TEXT     0x07
  120. #define COLOR_MODE     0x17
  121. #define COLOR_BLOCK    0x7f
  122. #define COLOR_MESSAGE  0x0f
  123. #define COLOR_HELP     0x1A
  124.  
  125. #define COLOR_80       3
  126. #define MONO_80        7
  127.  
  128. /*
  129.  * Some systems (like the PC) require a special kind of pointer for
  130.  *  arrays or structures larger than 64K.
  131.  *  (Note: only Turbo C's large data memory models
  132.  *  will compile correctly with this code.)
  133.  */
  134. #ifdef __TURBOC__
  135.    typedef char huge *text_ptr;
  136. #elif __MSC__
  137.    /*  typedef char huge *text_ptr; */
  138.    typedef char far *text_ptr;
  139. #else
  140.    typedef char *text_ptr;
  141. #endif
  142.  
  143. struct vcfg {
  144.    int color;
  145.    int rescan;
  146.    int mode;
  147.    int far *videomem;
  148. };
  149.  
  150.  
  151. typedef struct {
  152.    int  pattern_length;
  153.    int  search_case;
  154.    int  search_defined;
  155.    char pattern[MAX_COLS];
  156.    char skip_forward[256];
  157.    char skip_backward[256];
  158. } boyer_moore_type;
  159.  
  160.  
  161. /*
  162.  * "displays" contain all the status information about what attributes are
  163.  *  used for what purposes, which attribute is currently set, and so on.
  164.  * The editor only knows about one physical screen.
  165.  */
  166. typedef struct {
  167.     int line;                   /* actual line cursor currently on */
  168.     int col;                    /* actual column cursor currently in */
  169.     int nlines;                 /* lines on display device */
  170.     int ncols;                  /* columns on display device */
  171.     int line_length;            /* length of longest line */
  172.     int mode_line;              /* line to display editor modes - fmd */
  173.     int head_color;             /* file header color */
  174.     int text_color;             /* text area color */
  175.     int mode_color;             /* mode line color - footer */
  176.     int block_color;            /* hilited area of blocked region */
  177.     int message_color;          /* color of editor messages */
  178.     int help_color;             /* color of help screen */
  179.     char far *display_address;  /* address of display memory */
  180. } displays;
  181.  
  182. /*
  183.  * "status_infos" contain all the editor status information that is
  184.  *  global to the entire editor (i.e. not dependent on the file or
  185.  *  window)
  186.  */
  187. typedef struct {
  188.     struct s_windows *current_window;  /* current active window */
  189.     struct s_file_infos *current_file; /* current active file */
  190.     struct s_file_infos *file_list; /* all active files */
  191.     struct s_windows *window_list; /* all active windows */
  192.     int  file_count;             /* number of files currently open */
  193.     text_ptr start_mem;         /* first char in main text buffer */
  194.     text_ptr end_mem;           /* last char in main text buffer used+1 */
  195.     text_ptr temp_end;          /* temporary end_mem marker */
  196.     text_ptr max_mem;           /* last char available for storage (+1) */
  197.     int  prompt_col;             /* column for putting answer to prompt */
  198.     int  prompt_line;            /* line for putting answer to prompt */
  199.     int  insert;                 /* in insert mode? */
  200.     int  indent;                 /* in auto-indent mode? */
  201.     int  tab_size;               /* characters between tab stops */
  202.     int  marked;                 /* has block been marked? */
  203.     struct s_windows *marked_window;   /* pointer to window with marked block */
  204.     struct s_file_infos *marked_file;  /* pointer to file w/ marked block */
  205.     char rw_name[MAX_COLS];      /* name of last file read or written */
  206.     char pattern[MAX_COLS];      /* last search pattern */
  207.     char subst[MAX_COLS];        /* last substitute text */
  208.     int  replace_flag;           /* prompt or noprompt b4 replacing */
  209.     int  overlap;                /* overlap between pages for page up etc */
  210.     char line_buff[BUFF_SIZE+2]; /* for currently edited line */
  211. } status_infos;
  212.  
  213. /*
  214.  * "file_infos" contain all the information unique to a given file
  215.  */
  216. typedef struct s_file_infos {
  217.     text_ptr start_text;        /* first char in file */
  218.     text_ptr end_text;          /* last char in file (+1) */
  219.     long length;                /* number of lines in file */
  220.     int modified;               /* file has been modified since save? */
  221.     int new_file;               /* is current file new? */
  222.     char file_name[MAX_COLS];   /* name of current file being edited */
  223.     int block_type;             /* block type - line or block */
  224.     text_ptr block_start;       /* begining block position */
  225.     text_ptr block_end;         /* ending block position */
  226.     int  block_bc;              /* begining column */
  227.     long block_br;              /* begining row */
  228.     int  block_ec;              /* ending column */
  229.     long block_er;              /* ending row */
  230.     int ref_count;              /* no. of windows referring to file */
  231.     int file_attrib;            /* file attributes (rwx etc) */
  232.     struct s_file_infos *next;  /* next file in doubly linked list */
  233.     struct s_file_infos *prev;  /* previous file in doubly linked list */
  234. } file_infos;
  235.  
  236. /*
  237.  * "windows" contain all the information that is unique to a given
  238.  *  window.
  239.  */
  240. typedef struct s_windows {
  241.     file_infos *file_info;      /* file in window */
  242.     text_ptr cursor;            /* start of line containing cursor */
  243.     int ccol;                   /* column cursor logically in */
  244.     int rcol;                   /* column cursor actually in */
  245.     int bcol;                   /* base column to start display */
  246.     int cline;                  /* line cursor logically in */
  247.     long rline;                 /* real line cursor in */
  248.     int top_line;               /* top line in window */
  249.     int bottom_line;            /* bottom line in window */
  250.     int page;                   /* no. of lines to scroll for one page */
  251.     int visible;                /* window hidden or visible */
  252.     int dirty;                  /* file in window modified? */
  253.     struct s_windows *next;     /* next window in doubly linked list */
  254.     struct s_windows *prev;     /* previous window in doubly linked list */
  255. } windows;
  256.  
  257. /*
  258.  *  Use a dispatch array-structure to determine function of key pressed
  259.  *  by user.  Initialize it in "default.h".  Read in a configuration
  260.  *  file to change the key functions as desired by user coming soon.
  261.  */
  262.  
  263. typedef struct {
  264.    int   func;
  265. } DISPATCH_TABLE;
  266.